<%@ page import = "java.sql.*"%>
<%@ page import = "java.util.*" %>
<%@ page import= "java.io.*" %>


<%
try{
  
  String PathVariable="";
  
  PathVariable = "c:\\alex.csv";
  BufferedReader bufferedReader = null;
  try{

    bufferedReader = new BufferedReader(new FileReader(PathVariable));
  }
  catch(FileNotFoundException fnfe){

    fnfe.printStackTrace();

  }

  File f=new File("c:\\alex.csv");
  String fileType = "csv";
  if (fileType.trim().equalsIgnoreCase("txt")) {
    response.setContentType( "text/plain" );
  } else if (fileType.trim().equalsIgnoreCase("doc")) {
    response.setContentType( "application/msword" );
  } else if (fileType.trim().equalsIgnoreCase("xls")) {
    response.setContentType( "application/vnd.ms-excel" );
  } else if (fileType.trim().equalsIgnoreCase("pdf")) {
    response.setContentType( "application/pdf" );
  } else {
    response.setContentType( "application/octet-stream" );
  }
  String original_filename = "c:\\alex.csv";
  response.setHeader( "Content-Disposition", "attachment; filename=\"" + original_filename + "\"" );
  try{
    int anInt=0;

    while((anInt=bufferedReader.read())!=-1)
    out.write(anInt);

  }catch(IOException ioe){
    ioe.printStackTrace();
  }
}catch(Exception e){
  out.println("This is the Error " +e.getMessage());
}
%>
